-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Join the cool kids club (aka migrate to Gradle Kotlin DSL) #1321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Join the cool kids club (aka migrate to Gradle Kotlin DSL) #1321
Conversation
Signed-off-by: Alex Saveau <[email protected]>
# Conflicts: # auth/build.gradle # constants.gradle # library/quality/quality.gradle
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
@SUPERCILEX this is pretty cool! And does it fix the lint/aapt2 issue as well? If so I think we should release this as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly small comments
@@ -0,0 +1,59 @@ | |||
android { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a big comment on this file saying something like "hey we R cool kidz so we use the Kotlin DSL. If you're writing an app that uses FirebaseUI check out README.md for better examples" or something like that (please not that verbatim)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, I'm definitely going to quote you on that one! 😁 Side note: do you think we should rename :app
to :sample
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone ahead with that change though it's in one commit we can easily kill if you disagree.
auth/README.md
Outdated
@@ -135,7 +135,7 @@ Twitter app as reported by the [Twitter application manager](https://apps.twitte | |||
In addition, you must enable the "Request email addresses from users" permission | |||
in the "Permissions" tab of your Twitter app. | |||
|
|||
In order to resolve the Twitter SDK, add the following repository to your `build.gradle`: | |||
In order to resolve the Twitter SDK, add the following repository to your `build.gradle(.kts)`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use the longhand "build.gradle
or build.gradle.kts
" everywhere to minimize confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've decided to simply remove those references since our samples won't compile in gradle.kts anyway. 🤷♂️
auth/build.gradle.kts
Outdated
|
||
lintOptions { | ||
disable("UnusedQuantity") | ||
disable("UnknownNullness") // Too much to deal with right now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with the disabling but can you explain what's going on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I realize the nullability changes account for a lot more thrashing than originally anticipated. I've rebased those out and will make another PR with a better explanation. (As a short explanation, Tor is continuing his eternal quest to keep us on our toes with new lint checks. 😆)
build.gradle.kts
Outdated
val Project.reportsDir get() = "$buildDir/reports" | ||
|
||
fun Project.configureAndroid() { | ||
apply(plugin = "com.android.${if (name == "app" || name == "proguard-tests") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is over my personal fanciness limit :-)
How about:
if (name == "app" || name == "proguard-tests") {
// apply app plugin
} else {
// apply library plugin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, np. 😁😊
build.gradle.kts
Outdated
} | ||
|
||
fun Project.setupPublishing(isLibrary: Boolean) { | ||
val publicationName = "${if (isLibrary) "monolith" else name}Library" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer not to have expressions in strings. How about:
val publicationName = if (isLibrary) "monolithLibrary" else "${name}Library"
buildSrc/src/main/kotlin/Config.kt
Outdated
const val twitter = "com.twitter.sdk.android:twitter-core:3.1.1@aar" | ||
} | ||
|
||
object Miscellaneous { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit nit: shorten to Misc
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*Goes back to his own project to fix that too* 😆
"check"(this, block) | ||
} | ||
|
||
private inline operator fun String.invoke(project: Project, crossinline block: Task.() -> Unit) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm not super sold on this either, but I've seen similar DSL before: the idea is to override what happens when you call "someString"()
. In this case, we're saying you can do this:
"someTask"(myProject) {
// Do stuff with the task
}
I don't mind killing it if you're dumbfoundedly confused like how I felt the first time I saw that kind of DSL. 😁
@@ -20,7 +21,8 @@ public PageKey(@Nullable DocumentSnapshot startAfter, @Nullable DocumentSnapshot | |||
mEndBefore = endBefore; | |||
} | |||
|
|||
public Query getPageQuery(Query baseQuery, int size) { | |||
@NonNull |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the PR title to reflect all the nullability stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be moved into another PR
@@ -6,5 +6,5 @@ import com.android.tools.lint.client.api.IssueRegistry | |||
* Registry for custom FirebaseUI lint checks. | |||
*/ | |||
class LintIssueRegistry : IssueRegistry() { | |||
override fun getIssues() = listOf(NonGlobalIdDetector.NON_GLOBAL_ID) | |||
override val issues = listOf(NonGlobalIdDetector.NON_GLOBAL_ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
override val
--> Kotlin is cool but also sometimes it's stupid. This is not an actionable comment, just being grumpy Java guy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awww, c'mon!? How can you not love overriding fields? It's so clean! ✨
api(project(":auth")) | ||
api(project(":database")) | ||
api(project(":firestore")) | ||
api(project(":storage")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need common
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We didn't have it before and Gradle should take care of downloading those kinds of transitive dependencies.
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
@samtstern Yup, it fixes the lint issues and I've merged from 4.0.1. 👍 |
@SUPERCILEX LGTM but the one part I don't agree with is |
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
…-kotlin-dsl # Conflicts: # constants.gradle
SGTM, though do you think it should be done at some point? Personally, "app" has always felt vague. |
@SUPERCILEX I see |
Oh yeah, that makes sense since people will be familiar with it. 👍 |
@samtstern huh, I broke the snapshot builds. 😭 I'll look into it this afternoon. Is standard publishing working? |
Surprise, I found another way to use Kotlin in FUI! 🎉😁